#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Solution
{
public:
    static string countAndSay(int n)
    {
        string rs = "1";
        for(int i=1; i<n; i++)
        {
            int left = 0;
            int right = 0;
            string tmp;
            while(right < rs.size())
            {
                while(right < rs.size() && rs[left] == rs[right])
                {
                    right++;
                }
                tmp += to_string(right-left);
                tmp += rs[left];
                left = right;
            }
            rs = tmp;
        }
        return rs;
    }
};